/**
 * Created by lxh on 2018/1/3.
 */
import React,{PureComponent}from 'react';
import {connect} from 'dva';
import {Form, Input, Button, Radio, Checkbox, Modal, message,Table} from 'antd';
import {powerControl} from '../../../utils/powerControl';
const AuthButton = powerControl(Button);
const FormItem = Form.Item;
const RadioGroup = Radio.Group;
const CheckboxGroup = Checkbox.Group;
export default class SellerList extends PureComponent {
    state={

    }
    handleTableChange=(pagination)=>{
       this.props.handleTableChange(pagination);
    }
    handlePower=(record)=>{
        this.props.handlePower(record);
    }
    render() {
        const {data:{list,pagination}}=this.props;
        const columns = [{
            title: '商家ID',
            dataIndex: 'id',
            key: 'id',
            },{
                title: '店铺名称',
                dataIndex: 'shop_name',
                key: 'shop_name',
            }, {
                title: '店铺标题',
                dataIndex: 'shop_title',
                key: 'shop_title',
            }, {
                title: '详细地址',
                dataIndex: 'shop_address',
                key: 'shop_address',
            },{
            title:'操作',
            render:(text,record)=>{
                return (
                <Button.Group type="ghost">
                    <AuthButton type="primary" auth="powerConfig" onClick={()=>this.handlePower(record)}>权限配置</AuthButton>
                </Button.Group>

                )
            }
        }
        ];
        const paginationProps = {
            showSizeChanger: true,
            showQuickJumper: true,
            ...pagination,
        };
        const rowSelection = {
            onChange: (selectedRowKeys, selectedRows) => {
                this.setState({
                    selectedRow:Object.keys(selectedRows).map(function (key) {
                        return selectedRows[key].ACTION_ID;
                    })
                })
                console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
            },
            onSelect: (record, selected, selectedRows) => {
                console.log(record, selected, selectedRows);
            },
            onSelectAll: (selected, selectedRows, changeRows) => {
                console.log(selected, selectedRows, changeRows);
            },
        };

        const formItemLayout = {
            labelCol: {
                xs: {span: 24},
                sm: {span: 7},
            },
            wrapperCol: {
                xs: {span: 24},
                sm: {span: 12},
                md: {span: 10},
            },
        };

        const submitFormLayout = {
            wrapperCol: {
                xs: {span: 24, offset: 0},
                sm: {span: 10, offset: 7},
            },
        };
        return (
            <div>
                <div>
                    <Table
                        columns={columns}
                        dataSource={list}
                        rowKey={row => row.id}
                        pagination={paginationProps}
                        onChange={this.handleTableChange}
                    />
                </div>
            </div>
        );
    }
}


